package com.distance;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class BookmarksList extends Activity {
    ListView bookmarks;
    ArrayAdapter<String> mAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState){
	super.onCreate(savedInstanceState);
	setContentView(R.layout.bookmarkslist);

	setTitle("Distance - Select Bookmark to edit");
	bookmarks = (ListView)findViewById(R.id.BookmarksListLV01);
	mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Bookmarks.locationStrings);
	bookmarks.setAdapter(mAdapter);

	this.bookmarks.setOnItemClickListener(new OnItemClickListener(){

	    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
		    long arg3) {
		//Toast.makeText(Start.this, "test "+arg2, Toast.LENGTH_SHORT).show();
		//Route.start = Bookmarks.locationList.get(arg2);
		Bookmarks.detailedLocationPositionToEdit = arg2;
		Intent intent = new Intent();
		intent.setClassName("com.distance", "com.distance.EditBookmark");
		startActivity(intent);
	    }

	});
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK){
	    Intent intent = new Intent();
	    intent.setClassName("com.distance", "com.distance.Distance");
	    startActivity(intent);
	    return true;
	}
	return false;
    }

}
